﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Odbc;
using System.Data.Common;

/// <summary>
/// Summary description for MySQLDAOFactory
/// </summary>
public class MySQLDAOFactory : AbstractDAOFactory {
	protected IProfileDAO profileDAO;
	protected IScheduleDAO scheduleDAO;
	protected IDestinationDAO destinationDAO;

	//protected string connectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=App_Data\\Carpool.accdb;Uid=Admin;Pwd=;";
	//protected string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=~\\App_Data\\Carpool.accdb;Persist Security Info=False;";
	protected string connectionString = "dsn=Carpool2";

	public override DbConnection getConnection() {
		return new OdbcConnection(this.connectionString);
	}

	public MySQLDAOFactory() {}

	public override IProfileDAO createProfileDAO() {
		if (this.profileDAO == null) {
			this.profileDAO = new MySQLProfileDAOImpl(this);
		}
		return this.profileDAO;
	}

	public override IScheduleDAO createScheduleDAO() {
		if (this.scheduleDAO == null) {
			this.scheduleDAO = new MySQLScheduleDAOImpl(this);
		}
		return this.scheduleDAO;
	}

	public override IDestinationDAO createDestinationDAO() {
		if (this.destinationDAO == null) {
			this.destinationDAO = new MySQLDestinationDAOImpl(this);
		}
		return this.destinationDAO;
	}
}
